<template>
	<view class="">
		<scroll-view scroll-y="true" class="scroll">
			<view>
				<view>
					<view>
						<view v-for="(i,index) in Imageforall" :key="Imageforall.id">
							<view class="border">
								<view>
								{{i.name}}
								</view>
								<view class="scoref" v-show="i.isscore1">{{i.score1}}</view>
								<view class="desco" v-show="i.isdesco">{{i.deductedscore}}</view>
								
								<view class="btn" v-for="(j,index) in i.Imageall" :key="i.Imageall.id">
										<image :src="j.Image" style="width: 100rpx; height: 100rpx; margin-left: 20rpx; margin-top: 20rpx;" @click="checkimg(i,index)"></image>
										<button @click="addpicture(i,index)" :disabled="j.ban" class="picbtn">{{j.fname}}</button>
										<button @click="deducted(i,index)" class="scorebtn" v-show="j.isscorename">{{j.scorename}}</button>
										<button @click="canceldeducted(i,index)" class="scorebtn" v-show="j.isdscorename">{{j.cscorename}}</button>
										<button @click="remarkable(i,index)" class="remark">备注</button>
										<zwy-popup :ishide="i.uppo" width="750rpx" height="860rpx" :opacity="opacity" :cancelable="cancelable">
											<view class="tjid">
												<scroll-view scroll-y="true" class="uppoo">
													<view>
														<view class="" v-for="(s,index) in i.remarkall" :key="i.remarkall.id">
															<view class="uppoborder" @click="addremark(i,index,item)">{{s.remark}}</view>
														</view>
													</view>
												</scroll-view>
												<view class="delete" @click="isdele(i,index)">
													+
												</view>
											</view>
											
										</zwy-popup>

								<view class=""></view>
								</view>
							</view>
							<br>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="bottom-btn">
			<button @click="submit" class="bmbtn">完成</button>
		</view>
		<view v-show="showw">
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			<canvas :style="{width:canvasWidth,height:canvasHeight}" canvas-id="myCanvas" @click="checkimg"></canvas>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				falseremark:0,
				trueremark:null,
				det:4,
				dst:6,
				firstfirst:true,
				address:'',
				isstart: true,
				alist:[],
				count: 0,
				putremark: '',
				latitude: '',
				longitude: '',
				soyn:0,
				point:'',
				Evaluator: '',
				thisremark: true,
				isremark: true,
				cancelable:false,
				opacity:0.2,
				uppo:false,
				iaid:'',
				ifaid: '',
				Image: '',
				igid: '',
				n:0,
				sum2:[0,0,0,0,0,0,0,0,0],
				ggid:'',
				showw:true,
				photoData: [],
				photoArray: [],
				index:0,
				canvasWidth: '',
				canvasHeight: '',
				canvasnone:'',
				photoIndex: 0,
				photoData: '',
				Imageforall:[
					{
						id:'0',
						tid:11,
						firstfirst:true,
						first:true,
						remark: '',
						index:null,
						uppo:false,
						n: 0.6,
						point:'第12条',
						count:0,
						xpremark:null,
						sid:'1',
						remarkall:[
							{
								id:0,
								remark:'12.临街建（构）筑物遮阳篷做到单栋统一，整洁美观，底部距地面高度小于 2.5 米或妨碍疏散救援通道'
							},
							{
								id:1,
								remark:'12.阳台、平台、外走廊有超出墙体立面设置的防护网（栏）'
							},
							{
								id:2,
								remark:'12.安装空调、排气扇底部距地面低于 2米影响行人通行'
							},
							{
								id:3,
								remark:'12.冷凝水未接入排水管道使滴水积累影响居民生活'
							}
						],
						isimage: true,
						Imageall:[
							{
								id:'0',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'1',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'2',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'3',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'4',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'5',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'6',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							}
						],
						name:'12.临街建（构）筑物遮阳篷做到单栋统一，整洁美观，底部距地面高度小于 2.5 米或妨碍疏散救援通道的；阳台、平台、外走廊有超出墙体立面设置的防护网（栏）的；安装空调、排气扇底部距地面低于 2米影响行人通行的；冷凝水未接入排水管道使滴水积累影响居民生活的。',
						Image:'../../../static/th.jpg',
						fname:'点击进行拍照',
						sname:'点击重新拍照',
						scorename:'点击扣分',
						ban:true,
						score1:0,
						score2:0,
						score3:0,
						deductedscore:'已扣分',
						isdesco:false
					},
					{
						id:'1',
						tid:12,
						uppo:false,
						index:null,
						sid:'2',
						remarkall:[
							{
								id:0,
								remark:'13.空调外机、防盗网设置不整齐或歪倒（斜）存在安全隐患'
							},
							{
								id:1,
								remark:'13.外立面的电子显示屏、灯箱、广告牌、宣传标识等破损未修复或因积尘、污渍遮挡未清理影响宣传及景观效果'
							},
							{
								id:2,
								remark:'13.屋顶、门窗、装饰构件、标识、图案破损未修补'
							}
						],
						firstfirst:true,
						first:true,
						remark: '',
						n: 0.6,
						point:'第13条',
						count:0,
						xpremark:null,
						isimage: true,
						Imageall:[
							{
								id:'0',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'1',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'2',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'3',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'4',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'5',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'6',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							}
						],
						name:'13.空调外机、防盗网设置不整齐或歪倒（斜）存在安全隐患的；外立面的电子显示屏、灯箱、广告牌、宣传标识等破损未修复或因积尘、污渍遮挡未清理影响宣传及景观效果的；屋顶、门窗、装饰构件、标识、图案破损未修补的。',
						Image:'../../../static/th.jpg',
						fname:'点击进行拍照',
						sname:'点击重新拍照',
						scorename:'点击扣分',
						ban:true,
						score1:0,
						score2:0.1,
						score3:0.09,
						deductedscore:'已扣分',
						isdesco:false
					},
					{
						id:'2',
						tid:13,
						sid:'3',
						uppo:false,
						index:null,
						remarkall:[
							{
								id:0,
								remark:'14.各类电源线、电话线、网络连接线、电视信号线、监控器连接线、支撑线等做到“入地、入管”，无法入地入管的应“贴墙、捆扎”，架空线缆悬挂距地面不足 1.8 米的、掉落在房前屋后、路面上造成通行不便、影响美观'
							}
						],
						firstfirst:true,
						first:true,
						remark: '',
						n: 0.6,
						point:'第14条',
						count:0,
						xpremark:null,
						isimage: true,
						Imageall:[
							{
								id:'0',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'1',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'2',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'3',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'4',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'5',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							},
							{
								id:'6',
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:true,
								scorename:'扣分',
								cscorename: '取消',
								isscorename: true,
								isdscorename: false,
							}
						],
						name:'14.各类电源线、电话线、网络连接线、电视信号线、监控器连接线、支撑线等做到“入地、入管”，无法入地入管的应“贴墙、捆扎”，架空线缆悬挂距地面不足 1.8 米的、掉落在房前屋后、路面上造成通行不便、影响美观的。',
						Image:'../../../static/th.jpg',
						fname:'点击进行拍照',
						sname:'点击重新拍照',
						scorename:'点击扣分',
						ban:true,
						score1:0,
						score2:0.1,
						score3:0.09,
						deductedscore:'已扣分',
						isdesco:false
					}
				]
			}
		},
		onLoad() {
				console.log('你是谁')
				uni.getStorage({
					key: 'img11',
					success: res => {
						console.log('保存的')
						console.log(res)
						this.Imageforall = res.data
					}
				})
				uni.getStorage({
					key: 'det11',
					success: res => {
						console.log('保存的')
						console.log(res)
						this.det = res.data.det
						this.alist = res.data.alist
						this.soyn = res.data.soyn
						this.dst = res.data.dst
					}
				})
			
			console.log(this.$store.state.townclear)
			console.log(this.det)
		},
		methods: {
			isdele(e){
				e.uppo = false
			},
			addremark(e,b,c){
				console.log(e)
				console.log(b)
				console.log(c)
				// console.log(d)
				this.alist[this.trueremark].Imageall[this.alist[this.trueremark].Imageall.length - 1].remark = this.Imageforall[e.id].remarkall[b].remark
				e.uppo = false
				console.log(this.Imageforall)
				console.log(this.alist)
				uni.setStorage({
					key: 'img11',
					data: this.Imageforall,
					success: (res) => {
						console.log('成功了')
						console.log(res)
						console.log(this.Imageforall)
					}
				})
				// this.Imageforall[e.id].remarkall[b].remark = 
			},
			remarkable(e){
				e.uppo = true
				
				console.log(this.uppo)
			},
			getTime() {
					var date = new Date(),
						year = date.getFullYear(),
						month = date.getMonth() + 1,
						day = date.getDate(),
						hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
						minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
						second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
					month >= 1 && month <= 9 ? (month = "0" + month) : "";
					day >= 0 && day <= 9 ? (day = "0" + day) : "";
					var timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
					return timer;
				},
				canceldeducted(e, b) {
					uni.showModal({
						title: '提示',
						content: '是否对该条取消扣分',
						success: res => {
							var that = this
							if (res.confirm) {
								console.log('用户点击确定');
								console.log('vuex啊啊啊啊',that.$store.state.value)
								that.Imageforall[e.id].Imageall[b].isdscorename = false
								that.Imageforall[e.id].Imageall[b].isscorename = true
								that.Imageforall[e.id].Imageall[b].ban = true
								that.Imageforall[e.id].Imageall[b].Image = '../../../static/th.jpg'
								if (that.$store.state.value == 'A' || that.$store.state.value == 'B') {
									that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1 + 0.12
									that.$store.state.alltownscore[e.tid] = that.Imageforall[e.id].score1
									that.Imageforall[e.id].count -= 1
									console.log(that.Imageforall[e.id].score1)
								} else if (that.$store.state.value == 'C' || that.$store.state.value == 'D' || that.$store.state.value == 'E') {
									that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1 + 0.1
									that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1.toFixed(1)
									that.Imageforall[e.id].score1 = parseFloat(that.Imageforall[e.id].score1)
									that.$store.state.alltownscore[e.tid] = that.Imageforall[e.id].score1
									that.Imageforall[e.id].count -= 1
									console.log(that.Imageforall[e.id].score1)
								} else {
										console.log('第三类考评')
								}
			
								if (that.Imageforall[e.id].score1 == 0) {
									that.Imageforall[e.id].isdesco = false
									that.Imageforall[e.id].isscore1 = false
								}
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
					console.log(e.id)
					console.log(b)
					console.log(this.Imageforall)
				},
				deducted(e, b) {
					var that = this
					if(that.$store.state.value == 'C' || that.$store.state.value == 'D' || that.$store.state.value == 'E'){
						if (that.Imageforall[e.id].count > 5) {
							uni.showModal({
								title: '提示',
								content: '该指标已达到扣分上限',
								success: res => {
									if (res.confirm) {
										console.log('用户点击确定');
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							})
						} else {
							that.Imageforall[e.id].Imageall[b].isdscorename = true
							that.Imageforall[e.id].Imageall[b].isscorename = false
							console.log(e)
							console.log(b)
							that.ifaid = e.id
							that.iaid = b
							that.Imageforall[e.id].isdesco = true
							that.Imageforall[e.id].isscore1 = true
							that.Imageforall[e.id].Imageall[b].ban = false
							if (that.$store.state.value == 'A' || that.$store.state.value == 'B') {
								that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1 - 0.12
								that.$store.state.alltownscore[e.tid] = that.Imageforall[e.id].score1
								console.log(that.Imageforall[e.id].score1)
							} else if (that.$store.state.value == 'C' || that.$store.state.value == 'D' || that.$store.state.value == 'E') {
								that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1 - 0.1
								that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1.toFixed(1)
								that.Imageforall[e.id].score1 = parseFloat(that.Imageforall[e.id].score1)
								that.$store.state.alltownscore[e.tid] = that.Imageforall[e.id].score1
								console.log(that.Imageforall[e.id].score1)
							} else {
								console.log('第三类考评')
							}
							// this.Imageforall[e.id].score1 = this.Imageforall[e.id].score1 - 0.12
							that.sum2[e.id] = that.Imageforall[e.id].score1
							that.Imageforall[e.id].count += 1
							console.log('我用咖啡拉花拉出一跳白色的线，举一杯眷恋',that.$store.state.alltownscore)
							console.log(that.Imageforall[e.id].count)
							console.log('-------------------')
							console.log(that.sum2)
							console.log(that.Imageforall)
						}
					}
					if(that.$store.state.value == 'A' || that.$store.state.value == 'B'){
						if (that.Imageforall[e.id].count > 4) {
							uni.showModal({
								title: '提示',
								content: '该指标已达到扣分上限',
								success: res => {
									if (res.confirm) {
										console.log('用户点击确定');
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							})
						}else {
							that.Imageforall[e.id].Imageall[b].isdscorename = true
							that.Imageforall[e.id].Imageall[b].isscorename = false
							console.log(e)
							console.log(b)
							that.ifaid = e.id
							that.iaid = b
							that.Imageforall[e.id].isdesco = true
							that.Imageforall[e.id].isscore1 = true
							that.Imageforall[e.id].Imageall[b].ban = false
							if (that.$store.state.value == 'A' || that.$store.state.value == 'B') {
								that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1 - 0.12
								that.$store.state.alltownscore[e.tid] = that.Imageforall[e.id].score1
								console.log(that.Imageforall[e.id].score1)
							} else if (that.$store.state.value == 'C' || that.$store.state.value == 'D' || that.$store.state.value == 'E') {
								that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1 - 0.1
								that.Imageforall[e.id].score1 = that.Imageforall[e.id].score1.toFixed(1)
								that.Imageforall[e.id].score1 = parseFloat(that.Imageforall[e.id].score1)
								that.$store.state.alltownscore[e.tid] = that.Imageforall[e.id].score1
								console.log(that.Imageforall[e.id].score1)
							} else {
								console.log('第三类考评')
							}
							// this.Imageforall[e.id].score1 = this.Imageforall[e.id].score1 - 0.12
							that.sum2[e.id] = that.Imageforall[e.id].score1
							that.Imageforall[e.id].count += 1
							console.log('我用咖啡拉花拉出一跳白色的线，举一杯眷恋',that.$store.state.alltownscore)
							console.log(that.Imageforall[e.id].count)
							console.log('-------------------')
							console.log(that.sum2)
							console.log(that.Imageforall)
						}
					}
				},
				addpicture(e, b) {
					uni.chooseImage({
						count: 1,
						sourceType: ['camera'],
						success: (res) => {
							uni.showLoading({
								title:'正在加载...',
								mask:true
							})
							console.log(res)
							console.log(e)
							console.log(e.Imageall[e.id].id)
							this.ggid = e.id
							this.ifaid = e.id
							this.dst += 1
								var cd = this.dst
								var ig = {
								id:cd,
								remark:'无',
								isrecover:true,
								hk:null,
								Image:'../../../static/th.jpg',
								fname: '拍照',
								sname: '重拍',
								ban:false,
							}
							this.Imageforall[this.ifaid].Imageall.push(ig)
							this.iaid = b
							this.showw = true
							this.point = e.point
							if(this.Imageforall[e.id].xpremark == null){
								this.Imageforall[e.id].xpremark = this.falseremark
								this.falseremark += 1
								this.trueremark = this.Imageforall[e.id].xpremark
								console.log('falseremarkfalseremarkfalseremarkfalseremarkfalseremarkfalseremarkfalseremarkfalseremarkfalseremarkfalseremark',this.Imageforall[e.id].xpremark)
							} else {
								this.trueremark = this.Imageforall[e.id].xpremark
							}
							this.Imageforall[this.ifaid].Imageall[this.iaid].Image = res.tempFilePaths[0]
							console.log(res.tempFilePaths[0])
							uni.getLocation({
								type: 'wgs84',
								geocode: true,
								success: (res) => {
									uni.hideLoading()
									console.log(res)
									this.latitude = res.latitude
									this.longitude = res.longitude
									console.log(this.latitude)
									console.log(this.longitude)
									this.beforeAddWaterMart();
								},
								fail: function() {
									uni.showToast({
										title: '获取地址失败,请检查网络连接',
										icon: 'none'
									});
								}
							})
							// this.beforeAddWaterMart();
						}
					})
				},
				beforeAddWaterMart() {
					console.log('用了')
					this.addWaterMark(() => {
						if (this.photoIndex < this.photoArray.length - 1) {
							this.photoIndex++;
							this.beforeAddWaterMart()
						} else {
							uni.hideLoading()
						}
					})
				},
				addWaterMark(callback) {
					uni.showLoading({
						title: '正在加载水印...',
						mask: true
					})
					console.log('用了')
						uni.getImageInfo({
							src: this.Imageforall[this.ifaid].Imageall[this.iaid].Image,
							success: res => {
								console.log(res)
								this.time = this.getTime();
								if(this.canvasHeight != res.height || this.canvasWidth != res.width){
									this.canvasWidth = res.width + 'px'
									this.canvasHeight = res.height + 'px'
								} else {
									this.canvasWidth = res.width + 'px'
									this.canvasHeight = res.height + 'px'
								}
								var ctx = uni.createCanvasContext('myCanvas');
								setTimeout(()=> {
									ctx.drawImage(this.Imageforall[this.ifaid].Imageall[this.iaid].Image, 0, 0,res.width,res.height);
									// ctx.translate(res.width / 2, res.height / 2);
									ctx.beginPath();
									ctx.setFontSize(40);
									ctx.setFillStyle("white")
									ctx.fillText('地点:' + this.$store.state.address, 0, 100)
									ctx.fillText(this.time, 0, 200);
									ctx.fillText('纬度:' + this.latitude + '  ' + '经度:' + this.longitude, 0, 300)
									ctx.draw(false, () => {
										console.log('用了')
											console.log("asdf")
											uni.canvasToTempFilePath({
												canvasId: "myCanvas",
												success: res => {
													console.log(res.tempFilePath)
													// this.Imageforall[this.ifaid].Imageall[this
													// 	.iaid].Image = res.tempFilePath;
													this.showw = false
													this.tempFilePath = res.tempFilePath
													// var formData = new FormData();
													//     formData.append('file', this.tempFilePath);
													console.log(this.Imageforall)
													uni.compressImage({
														src:res.tempFilePath,
														quality:0,
														success: (res) => {
															uni.compressImage({
																src:res.tempFilePath,
																quality:0,
																success: (res) => {
																	
																			uni.saveImageToPhotosAlbum({
																		filePath: res.tempFilePath,
																		success: (res) => {
																			this.Imageforall[this.ifaid].Imageall[this.iaid].Image = res.path;
																			console.log(res)
																			// uni.uploadFile({
																			// 	url: 'http://192.168.0.37:8000/kaoping/evidence/image/',
																			// 	filePath: this.Imageforall[this.ifaid].Imageall[this.iaid].Image,
																			// 	name: 'image',
																			// 	success: res => {
																			// 		uni.showToast({
																			// 			title: "保存成功",
																			// 			icon: "none"
																			// 		});
																			// 		setTimeout
																			// 			(() => {
																			// 					uni.hideLoading()
																			// 				},
																			// 				2000
																			// 				)
																			// 		console.log('错误')
																			// 		console.log(res)
																			// 		console.log(this.Imageforall[this.ifaid].Imageall[this.iaid].Image)
																			// 	}
																			// })
																			if(this.Imageforall[this.ifaid].first){
																				this.Imageforall[this.ifaid].Imageall[this.iaid].hk = this.soyn
																				this.Imageforall[this.ifaid].index = this.index
																				this.index += 1
																				this.soyn += 1
																				this.Imageforall[this.ifaid].first = false
																				var sa = {
																					point:this.point,
																					name:this.Imageforall[this.ifaid].name,
																					Imageall:[
																						{
																							remark:'无',
																							Image:this.Imageforall[this.ifaid].Imageall[this.iaid].Image,
																						}
																					]
																				}
																				this.alist.push(sa)
																				var set = new Set(this.alist)
																				var thisset = [...set]
																				this.alllist = thisset
																				console.log('巴士克特波',this.alllist)
																				if(this.firstfirst){
																					this.Imageforall[this.ifaid].firstfirst = false
																					// this.$store.state.decifm.push(...this.alist)
																				} else {
																					// this.$store.state.decifm.push(...sa)
																				}
																					console.log(this.$store.state.decifm)
																			} else {
																				if(this.Imageforall[this.ifaid].Imageall[this.iaid].hk == null){
																					this.Imageforall[this.ifaid].Imageall[this.iaid].hk = this.soyn
																					this.soyn += 1
																					var ta = {
																						remark:'无',
																						Image:this.Imageforall[this.ifaid].Imageall[this.iaid].Image
																					}
																					this.alist[this.Imageforall[this.ifaid].index].Imageall.push(ta)
																					console.log(ta)
																					// this.$store.state.decifm[this.ifaid].Imageall.push(ta)
																					console.log(this.$store.state.decifm)
																					var set = new Set(this.alist)
																					var thisset = [...set]
																					this.alist = thisset
																					console.log('巴士克特波',this.alist)
																				} else {
																					var recover = this.Imageforall[this.ifaid].Imageall[this.iaid].Image
																					this.alist[this.Imageforall[this.ifaid].index].Imageall[this.Imageforall[this.ifaid].Imageall[this.iaid].hk].Image = recover
																					console.log(recover)
																					// this.$store.state.decifm[this.ifaid].Imageall.push(ta)
																					console.log(this.$store.state.decifm)
																					var set = new Set(this.alist)
																					var thisset = [...set]
																					this.alist = thisset
																					console.log('巴士克特波',this.alist)
																					console.log(this.Imageforall[this.ifaid].Imageall[this.iaid].hk)
																				}
																			}
																			console.log(this.Imageforall[this.ifaid].first)
																			console.log('它来了它来了',this.alist)
																			
																		console.log(this.Imageforall)
																			// console.log(this.$store.state.decifm)
																			uni.setStorage({
																				key: 'img11',
																				data: this.Imageforall,
																				success: (res) => {
																					console.log('成功了')
																					console.log(res)
																					console.log(this.Imageforall)
																				}
																			})
																			uni.setStorage({
																				key: 'det11',
																				data: {
																					det:this.det,
																					alist:this.alist,
																					soyn:this.soyn,
																					dst:this.dst,
																					index:this.index
																				},
																				success: (res) => {
																					console.log('成功了')
																					console.log(res)
																					console.log(this.dst)
																				}
																			})
																			uni.setStorage({
																				key:'town',
																				data:this.$store.state.alltownscore,
																				success: (res) => {
																					console.log(res)
																					console.log(this.$store.state.alltownscore)
																				}
																			})
																			uni.showToast({
																				title: "保存成功",
																				icon: "none"
																			});
																		},
																		fail: err => {
																			console.log(err)
																			uni.showToast({
																				title: "保存失败，请稍后重试",
																				icon: "none"
																			});
																		}
																	});
																		
																}
															})
														}
													})
													
													uni.showToast({
														title: '加载成功',
														icon: 'success',
														duration: 2000,
														mask:true
													})
													callback();
													console.log('用完了')
												}
											})
									});
								},100)
							},
							fail: function() {
								uni.showToast({
									title: '获取图片失败',
									icon: 'none'
								});
							}
						})
					
				},
				checkimg(e, b) {
					console.log(e)
					console.log(b)
					uni.previewImage({
						urls: [this.Imageforall[e.id].Imageall[b].Image],
						success: (res) => {
							console.log(this.Imageforall[e.id].Imageall[b].Image)
						},
						fail: function() {
							uni.showToast({
								title: '网络错误,请检查网络连接',
								icon: 'none'
							});
						}
					})
				},
				submit() {
					this.$store.state.decifm.push(...this.alist)
					const combinedData = this.$store.state.decifm.reduce((acc, cur) => {
					  const found = acc.find(obj => obj.name === cur.name);
					  if (found) {
					    found.Imageall.push(...cur.Imageall);
					  } else {
					    acc.push(cur);
					  }
					  return acc;
					}, []);
					console.log(combinedData);
					const uniqueArr = combinedData.filter((item, index) => {
					  return combinedData.findIndex(obj => {
					    return JSON.stringify(obj) === JSON.stringify(item);
					  }) === index;
					});
					this.$store.state.decifm = uniqueArr
					console.log(uniqueArr);
					var thedec = new Set(this.$store.state.decifm)
					console.log(thedec)
					var truedec = [...thedec]
					this.$store.state.decifm = truedec
					console.log(truedec)
					this.$store.state.decifm.forEach((item) => {
					  const lb = new Set(item.Imageall.map((image) => image.Image));
					  item.Imageall = Array.from(lb).map((image) => {
					    return item.Imageall.find((img) => img.Image === image);
					  });
					});
					console.log(this.Imageforall)
					uni.showToast({
						title:'保存成功'
					})
					uni.setStorage({
						key: 'alldecifm',
						data: this.$store.state.decifm,
						success: (res) => {
							console.log(res)
						}
					})
					// uni.request({
					// 	url: 'http://192.168.0.37:8000/kaoping/excelfile/',
					// 	method: 'POST',
					// 	data: {
					// 		name: 'sad',
					// 		score_list: this.sum2,
					// 		category: '123',
					// 		position: '2222'
					// 	},
					// 	success: res => {
					// 		console.log('传好了')
					// 		console.log(res)
					// 	}
					// })
				}
			}
	}
</script>

<style>
	.uppoborder {
		width: 750rpx;
		border: 1px solid skyblue;
		background-color: #F8F8FF;
		text-align: center;
		margin-top: 10rpx;
	}
	.uppoborder:active {
		background-color: deepskyblue;
	}
	.tjid {
		width: 750rpx;
		height: 860rpx;
		background-color: #363636;
		
		
		/* transform: rotate(45deg); */
		/* opacity: 0; */
	}
	.delete {
		position: fixed; 
		bottom: 0;
		/* right: 200rpx; */
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
		margin-left: 365rpx;
		margin-top: 960rpx;
		transform: rotate(45deg);
		color: white;
		font-size: 80rpx;
		text-align: center;
		/* background-color: pink; */
		
	}
	.remark {
		font-size: 20rpx;
		width: 100rpx;
		height: 50rpx;
		background-color: pink;
		margin-left: 20rpx;
		margin-top: 10rpx;
	}
	.uppoo {
		/* float: left; */
		background-color: white;
		width: 750rpx;
		height: 750rpx;
		/* opacity: 0.1; */
		z-index: 1;
	}
	.scroll {
		height: 100%;
	}
	.picbtn {
		/* float: left; */
		font-size: 20rpx;
		width: 100rpx;
		height: 50rpx;
		background-color: pink;
		margin-left: 20rpx;
		margin-top: 10rpx;
	}
	
	.bottom-btn {
		position: fixed;
		margin-top: 20rpx;
		width: 100%;
		bottom: 0rpx;
	}
	
	.bmbtn {
		background-color: skyblue;
		color: whitesmoke;
	}
	
	.bmbtn:active {
		background-color: deepskyblue;
	}
	
	
	.scorebtn {
		font-size: 20rpx;
		/* margin-top: -50rpx; */
		width: 100rpx;
		height: 50rpx;
		margin-top: 15rpx;
		margin-left: 20rpx;
		/* margin-left: 450rpx; */
		/* background-color: pink; */
	}
	
	.btn {
		float: left;
		/* margin-top: 150rpx; */
	}
	.border {
		clear: both;
		width: 750rpx;
		border: 1px solid skyblue;
		background-color: #F8F8FF;
	}
	.desco {
		float: right;
		width: 115rpx;
		height: 115rpx;
		line-height: 110rpx;
		text-align: center;
		/* margin-left: 600rpx; */
		margin-right: 25rpx;
		margin-top: 15rpx;
		border-radius: 50%;
		border: 1px solid red;
		/* background-color: red; */
		color: red;
	}
	.scoref {
		float: right;
		/* margin-left: 300rpx; */
		margin-right: 20rpx;
		margin-top: -50rpx;
		color: red;
	}
</style>